Built-in Modules > print Function
print Function
Overview
The print
function is a server-side tool designed to display the values of variables in the output, similar to console.log()
in client-side JavaScript.
Function Definition
function print(name, variable_to_print) {
// Function to print variable values
}
Usage Example
import { print } from "./modules.js"
print("x", x); // Where "x" is the name of the print and x is any variable.
In this example, print
is used to display the value of the variable x
. The first argument "x"
is a string representing the name of the print, which can be any descriptive string.
Notes
- The
print
function requires two mandatory arguments:- The first argument is a string that serves as the name or label for the print.
- The second argument is the variable whose value needs to be printed.
- It is important to use the
print
function instead ofconsole.log()
orconsole.error()
in the JsRates editor, asconsole.log()
andconsole.error()
are not supported. - This function is particularly useful for debugging purposes, allowing you to track the values of variables during the execution of your code on the JsRates server.
The print
function enhances the debugging process by providing a server-side equivalent to console.log()
, ensuring developers can monitor variable states effectively.